package LuoGu.二分查找.高考志愿;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;

public class Main_RE {
    public static void main(String[] args) throws IOException {
        StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        st.nextToken();
        int n = (int) st.nval;
        st.nextToken();
        int m = (int) st.nval;
        int [] schools = new int[n];
        int [] students = new int[m];
        for(int i=0;i<n;i++){
            st.nextToken();
            schools[i] = (int) st.nval;
        }
        Arrays.sort(schools);
        for(int i=0;i<m;i++){
            st.nextToken();
            students[i] = (int) st.nval;
        }
        long ans = 0;
        //注意二分查找的边界，一定要小于n-1（如果下标从0开始）
        for(int i=0;i<m;i++){
            int l = 0;
            int r = n-1;            //会RE都是因为 r的设置，使数组下标超限
            int m1 = (l+r)/2;
            while(l<r){
                if(schools[m1]>=students[i]) r = m1;
                else l = m1+1;
                m1 = (l+r)/2;
            }
            int temp = Math.abs(schools[l]-students[i]);
            if(schools[0]>students[i]) ans+=temp;
            else ans+=Math.min(temp,Math.abs(schools[l-1]-students[i]));
        }
        System.out.print(ans);
    }
}
